package com.hzhr.iot.cqgas.ds.controller;

import com.hzhr.iot.cqgas.ds.dao.device.example.DevCollectDeviceTypeDao;
import com.hzhr.iot.cqgas.ds.entity.device.DevCollectDeviceTypeEntity;
import com.hzhr.iot.cqgas.ds.entity.device.DevCollectDeviceTypeExample;
import com.hzhr.iot.cqgas.ds.service.CollectDeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CollectDeviceTypeController {
    @Autowired
    CollectDeviceTypeService collectDeviceTypeService;
    @Autowired
    DevCollectDeviceTypeDao devCollectDeviceTypeDao;

    @RequestMapping(value = "/syncCollectDeviceType")
    public void syncCollectDeviceType() {
        DevCollectDeviceTypeEntity devCollectDeviceTypeEntity = new DevCollectDeviceTypeEntity();
        devCollectDeviceTypeEntity.setState("3");
        DevCollectDeviceTypeExample devCollectDeviceTypeExample = new DevCollectDeviceTypeExample();
        devCollectDeviceTypeExample.createCriteria().andOutIdIsNotNull();
        devCollectDeviceTypeDao.updateByExampleSelective(devCollectDeviceTypeEntity, devCollectDeviceTypeExample);

        collectDeviceTypeService.syncCollectDeviceType();

        devCollectDeviceTypeExample = new DevCollectDeviceTypeExample();
        devCollectDeviceTypeExample.createCriteria().andStateEqualTo("3");
        devCollectDeviceTypeDao.deleteByExample(devCollectDeviceTypeExample);
    }
}
